﻿//===================================================================
// 西交通开发框架-XCI.Parent 2019 版权所有     
//===================================================================
using System;
using System.ComponentModel.DataAnnotations;
using XCI.Annotations;
using XCI.Data.Entity;

namespace XCI.Sys.Model
{
    /// <summary>
    /// 系统用户
    /// </summary>
    [Table("系统用户")]
    public class SysUser
    {
        /// <summary>
        /// 用户主键
        /// </summary>
        [Primary]
        [Column("用户主键", false)]
        public string Id { get; set; }

        /// <summary>
        /// 用户姓名
        /// </summary>
        [Column("用户姓名")]
        [Required(ErrorMessage = "请输入用户姓名")]
        [StringLength(100, ErrorMessage = "用户姓名不能超过100个字符")]
        public string Name { get; set; }

        /// <summary>
        /// 用户姓名简拼
        /// </summary>
        [Column("用户姓名简拼", false)]
        [StringLength(100, ErrorMessage = "用户姓名简拼不能超过100个字符")]
        public string Spell { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        [Column("账号")]
        [Required(ErrorMessage = "请输入账号")]
        [StringLength(100, ErrorMessage = "账号不能超过100个字符")]
        public string Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Column("密码")]
        [StringLength(100, ErrorMessage = "密码不能超过100个字符")]
        public string Password { get; set; }

        /// <summary>
        /// 密码盐
        /// </summary>
        [Column("密码盐")]
        [StringLength(100, ErrorMessage = "密码盐不能超过100个字符")]
        public string Salt { get; set; }

        /// <summary>
        /// 手机号码
        /// </summary>
        [Column("手机号码")]
        [StringLength(100, ErrorMessage = "手机号码不能超过100个字符")]
        [MobilePhone]
        public string Mobile { get; set; }

        /// <summary>
        /// 电子邮件
        /// </summary>
        [Column("电子邮件")]
        [StringLength(100, ErrorMessage = "电子邮件不能超过100个字符")]
        [Email]
        public string Email { get; set; }

        /// <summary>
        /// 部门主键
        /// </summary>
        [Column("部门主键")]
        public string DeptId { get; set; }

        /// <summary>
        /// 部门名称
        /// </summary>
        [Column("部门名称")]
        [Required(ErrorMessage = "请输入部门名称")]
        [StringLength(100, ErrorMessage = "部门名称不能超过100个字符")]
        public string DeptName { get; set; }

        /// <summary>
        /// 登录次数
        /// </summary>
        [Column("登录次数")]
        public int? LoginNumber { get; set; }

        /// <summary>
        /// 管理员(0:否;1:是)
        /// </summary>
        [Column("管理员(0:否;1:是)")]
        public bool? Admin { get; set; }

        /// <summary>
        /// 首次登录时间
        /// </summary>
        [Column("首次登录时间")]
        public DateTime? FirstVisitTime { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        [Column("最后登录时间")]
        public DateTime? LastVisitTime { get; set; }

        /// <summary>
        /// 开始有效期
        /// </summary>
        [Column("开始有效期")]
        [Display(Name = "开始有效期")]
        public DateTime? AllowStartTime { get; set; }

        /// <summary>
        /// 结束有效期
        /// </summary>
        [Column("结束有效期")]
        [Display(Name = "结束有效期")]
        [CompareDate(nameof(AllowStartTime), DateCompareType.GreatThan)]
        public DateTime? AllowEndTime { get; set; }

        /// <summary>
        /// 启用状态
        /// </summary>
        [Column("启用")]
        public bool? Status { get; set; }

        /// <summary>
        /// 是否过期
        /// </summary>
        [Column("过期")]
        public bool IsExpire { get; set; }

        /// <summary>
        /// 有效状态
        /// </summary>
        [Column("有效")]
        public bool ValidStatus { get { return !IsExpire; } }

        /// <summary>
        /// 备注
        /// </summary>
        [Column("备注")]
        [StringLength(500, ErrorMessage = "备注不能超过500个字符")]
        public string Remark { get; set; }

        /// <summary>
        /// 角色主键字符串
        /// </summary>
        [Column("角色主键字符串", Visable = false)]
        public string RoleIds { get; set; }

        /// <summary>
        /// 用户登录凭据
        /// </summary>
        [Column("用户登录凭据", Visable = false)]
        public string Token { get; set; }

        /// <summary>
        /// 复制对象
        /// </summary>
        public SysUser Clone()
        {
            return (SysUser)MemberwiseClone();
        }
    }
}
